//
//  YIem_SY_One_ViewModel.m
//  B段_开眼
//
//  Created by YIem on 16/5/6.
//  Copyright © 2016年 Howie. All rights reserved.
//

#import "YIem_SY_One_ViewModel.h"
#import "YIem_SY_One_Model.h"
@implementation YIem_SY_One_ViewModel
+ (void)getDataWithPage:(NSString *)nextPage andUpdate:(BOOL)isUpdate andBlock:(void (^)(NSMutableDictionary *))tableDic
{
    [CustomerNetWorking connectWithURL:nextPage andUpdate:isUpdate andBlock:^(id response)
     {
         NSMutableDictionary *dic = [NSMutableDictionary dictionary];

         NSMutableArray *indexArray = [NSMutableArray array];
         NSMutableArray *weatherArray = [NSMutableArray array];

         for (NSDictionary *tempdic in [response objectForKey:@"results"]) {
             for (NSDictionary *indexDic in [tempdic objectForKey:@"index"]) {
                 YIem_SY_One_Model *model = [[YIem_SY_One_Model alloc] init];
                 [model setValuesForKeysWithDictionary:indexDic];
                 [indexArray addObject:model];
             }
             for (NSDictionary *weatherDic in [tempdic objectForKey:@"weather_data"]) {
                 YIem_SY_One_Model *model = [[YIem_SY_One_Model alloc] init];
                 [model setValuesForKeysWithDictionary:weatherDic];
                 [weatherArray addObject:model];
             }
             
             [dic setObject:[tempdic objectForKey:@"currentCity"] forKey:@"currentCity"];
             [dic setObject:[tempdic objectForKey:@"pm25"] forKey:@"pm25"];
             [dic setObject:indexArray forKey:@"index"];
             [dic setObject:weatherArray forKey:@"weather"];
         }
       
         
         tableDic(dic);
     }];
    
}
@end
